package example03;

import java.awt.*;
import javax.swing.*;

import net.sf.jeppers.grid.*;

/**
 * Paint negative numbers red
 */
class NamedColorRenderer extends GenericCellRenderer {
    public Component getRendererComponent(
        int row,
        int column,
        Object value,
        CellStyle style,
        boolean isSelected,
        boolean hasFocus,
        JGrid grid) {
        Component comp =
            super.getRendererComponent(
                row,
                column,
                value,
                style,
                isSelected,
                hasFocus,
                grid);
        setHorizontalAlignment(SwingConstants.CENTER);
		NamedColor color = (NamedColor) value;
		setBackground(color);
		setForeground(color.getTextColor());
		setText(color.toString());		
        return comp;
    }
}